<?php
	ob_start();
	session_start();

	function __autoload($class_name) {
	include './'.$class_name . '.php';
	}
	
	function test_input($data) {
		$data = trim($data);
		$data = stripslashes($data);
		$data = htmlspecialchars($data);
		return $data;
	}
	
	$dbConfig = new DBConfigNew(); 
	$conn = $dbConfig->getConnection();
	$mysqli=$conn;
	$result = array();
	$status = true;	
	$name = null;
	$contact = null;
	$stmt = null;
	$query = "CALL pyramid.contact_i(?,?);";
	
	if ($_SERVER["REQUEST_METHOD"] == "GET") {
		if (isset($_GET["name"])){
			$name = test_input($_GET["name"]);		
		}
		if (isset($_GET["contact"])){
			$contact = test_input($_GET["contact"]);		
		}
	}
	if ($name == null || $name == "" || $contact == null || $contact == "" ){
		$status = false;
	}
	
	$stmt = $mysqli->prepare($query);
	$stmt->bind_param("ss", $name, $contact); 
	
	
	if($status && !$stmt->execute()){
		$status = false;
	}
	
	$results['success'] = $status;
	//$results['success'] = 'false';
	echo json_encode($results);
	
	ob_end_flush();
?>